#!/usr/bin/env python
# -*- coding:utf-8 -*-

from flask_restful import Api

from . import wordbook_blueprint
from api_1_0.wordbookResource.wordbookResource import WordbookResource
from api_1_0.wordbookResource.wordbookOtherResource import WordbookOtherResource

api = Api(wordbook_blueprint)

api.add_resource(WordbookResource, '/<wordbook_id>', '', endpoint='Wordbook')


@wordbook_blueprint.route('/update/<wordbook_id>', methods=['PUT'], endpoint='WordbookUpdate')
def update(wordbook_id):
    return WordbookOtherResource.sensitive_update(wordbook_id)

# 新建单词本
@wordbook_blueprint.route('/create', methods=['POST'], endpoint='CreateWordbook')
def create_wordbook():
    return WordbookOtherResource.create_wordbook()

@wordbook_blueprint.route('/add_word_to_wordbook', methods=['POST'], endpoint='addWordbook')
def add_word_to_wordbook():
    return WordbookOtherResource.add_word_to_wordbook()

# 获取按顺序或逆序排列的单词本中的单词
@wordbook_blueprint.route('/<wordbook_id>/words', methods=['GET'], endpoint='getSortedWords')
def get_sorted_words(wordbook_id):
    return WordbookOtherResource.get_sorted_words(wordbook_id)


# 获取某人的单词本列表
@wordbook_blueprint.route('/user_wordbooks', methods=['POST'], endpoint='getUserWordbooks')
def get_user_wordbooks():
    return WordbookOtherResource.get_user_wordbooks()